/**************************************
*       Class AppletURLReader
***************************************/
import java.net.*;
import java.io.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class AppletURLReader extends Applet implements ActionListener
{
  URL gis;
  BufferedReader in;
  TextArea gumText;

  public void init() {
    setLayout( new BorderLayout() );
    gumText = new TextArea("", 10,100);
    add(gumText, "Center");
    Button b = new Button("Get GUM Data");
    b.addActionListener(this);
    add(b, "South");

    String paraName;
    String map;
    int    paraIndex = 1;

    paraName = "map" + paraIndex;
    map = getParameter(paraName);

    try {
      gis = new URL(getDocumentBase(), map);
      System.out.println(gis);
    }
    catch(Exception e){
      System.out.println(e);
    }
  }

  public void actionPerformed(ActionEvent e) {
    try {
      in = new BufferedReader( new InputStreamReader( gis.openStream() ) );

      String line, lineSeparator;
      lineSeparator = System.getProperty("line.separator");

      while( (line = in.readLine()) != null ) {
        gumText.append(line + lineSeparator);
      }

      in.close();
    }
    catch(Exception ex) {
      System.out.println(ex);
    }
  }
}
